#version 300 es
#extension GL_OES_EGL_image_external_essl3 : require
precision highp float;
uniform samplerExternalOES s_TextureMap;
uniform float uValue;
uniform vec2 iResolution;
in vec2 texCoord;
out vec4 outColor;
void main()
{
    //一次抖动效果的时长
    float duration = 0.7;
    //放大图片的上限
    float maxScale = 1.1;
    //颜色偏移的步长
    float offset = 0.02;

    //进度 0 ~ 1
    float progress = mod(uValue, duration) / duration;
    //颜色偏移值0 ~ 0.02
    vec2 offsetCoords = vec2(offset, offset) * progress;
    //缩放比例 1.0 ~ 1.1
    float scale = 1.0 + (maxScale - 1.0) * progress;

    //放大后的纹理坐标
    //下面这种向量相加减的方式 等价于 灵魂出窍滤镜中的单个计算x、y坐标再组合的为纹理坐标的方式
    vec2 ScaleTextureCoords = vec2(0.5, 0.5) + (texCoord - vec2(0.5, 0.5)) / scale;

    //获取三组颜色：颜色偏移计算可以随意，只要偏移量很小即可
    //原始颜色 + offset
    vec4 maskR = texture(s_TextureMap, ScaleTextureCoords + offsetCoords);
    //原始颜色 - offset
    vec4 maskB = texture(s_TextureMap, ScaleTextureCoords - offsetCoords);
    //原始颜色
    vec4 mask = texture(s_TextureMap, ScaleTextureCoords);

    //从3组颜色中分别取出 红色R，绿色G，蓝色B，透明度A填充到内置变量gl_FragColor内
    outColor = vec4(maskR.r, maskB.g, mask.b, mask.a);
}